home *** CD-ROM | disk | FTP | other *** search
/ PC Open 97 / PC Open 97 CD2.bin / Demo / FileMaker / Data1.cab / custom_delim.xsl4 < prev    next >
Encoding:
Extensible Markup Language  |  2002-05-24  |  3.7 KB  |  106 lines

  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fmp="http://www.filemaker.com/fmpxmlresult">
  3.     <xsl:output method="text" version="1.0" encoding="UTF-8" indent="no"/>
  4.     <!--
  5. File: custom_delim.xsl
  6.  
  7. Transforms data in FMPXMLRESULT grammar into a text file with the 
  8. specified characters as field and record delimiters.
  9.  
  10. Note that it is possible to choose field and record delimiters 
  11. that would result in an exported file that FileMaker Pro can no
  12. longer import.
  13.  
  14. For example:
  15.  
  16. Database data
  17. =============
  18. White     Johnson  Red       33
  19. Green     Mark     Red      100 
  20. Blue      Sam      Blue     201 
  21. Yellow    Susan    Green    839 
  22. Straight  Wendy    Orange    22
  23.  
  24. Output
  25. ======
  26. White*Johnson*Red*33
  27. Green*Mark*Red*100 
  28. Blue*Sam*Blue*201 
  29. Yellow*Susan*Green*839 
  30. Straight*Wendy*Orange*22
  31.  
  32. ===============================================================
  33.  
  34. Copyright ┬⌐ 2002 FileMaker, Inc.
  35. All rights reserved.
  36.  
  37. Redistribution and use in source and binary forms, with or
  38. without modification, are permitted provided that the following
  39. conditions are met:
  40.  
  41. * Redistributions of source code must retain the above copyright
  42.   notice, this list of conditions and the following disclaimer.
  43.  
  44. * Redistributions in binary form must reproduce the above copyright
  45.   notice, this list of conditions and the following disclaimer in 
  46.   the documentation and/or other materials provided with the
  47.   distribution.
  48.  
  49. * Neither the name of the FileMaker, Inc. nor the names of its 
  50.   contributors may be used to endorse or promote products derived
  51.   from this software without specific prior written
  52.   permission.
  53.  
  54. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
  55. CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
  56. INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
  57. MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 
  58. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR 
  59. ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 
  60. CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
  61. SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
  62. BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
  63. WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  64. NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  65. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  66.     
  67. ===============================================================
  68. -->
  69.     <xsl:template match="fmp:FMPXMLRESULT">
  70.         <xsl:for-each select="fmp:RESULTSET/fmp:ROW">
  71.             <xsl:for-each select="fmp:COL">
  72.                 <xsl:choose>
  73.                     <xsl:when test="position()=last()">
  74.                         <xsl:value-of select="fmp:DATA"/>
  75.                     </xsl:when>
  76.                     <xsl:otherwise>
  77.                         <xsl:value-of select="fmp:DATA"/>
  78.                         <xsl:value-of select="$delimiter"/>
  79.                     </xsl:otherwise>
  80.                 </xsl:choose>
  81.             </xsl:for-each>
  82.             <xsl:value-of select="$newrecord"/>
  83.         </xsl:for-each>
  84.     </xsl:template>
  85.     <!--  
  86. Variable "delimiter" contains the character that will be inserted in the output
  87. between each field in the exported data.
  88.             
  89. Change the "*" between the "xsl:text" tags to make customizations.
  90.     -->
  91.     <xsl:variable name="delimiter">
  92.         <xsl:text>*</xsl:text>
  93.     </xsl:variable>
  94.     <!--  
  95. Variable "newline" contains the character that will be inserted in the output as the
  96. end of record character.
  97.             
  98. By default the new record delimitter is a carriage return. Other characters may be
  99. inserted between the xsl:text tags to create different delimitters.
  100.     -->
  101. <xsl:variable name="newrecord">
  102. <xsl:text>
  103. </xsl:text>
  104. </xsl:variable>
  105. </xsl:stylesheet>
  106.